#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import asyncio

async def test_simple_stream():
    """简单的流式测试"""
    print("🚀 开始简单流式测试...")
    
    try:
        from util.llm import sse_request
        
        print("✅ 导入成功")
        
        # 测试流式输出
        print("🔍 开始流式输出...")
        chunk_count = 0
        
        async for chunk in sse_request(
            system_prompt="你是一个有用的助手。",
            history=[],
            prompt="请简单介绍一下你自己。",
            model="deepseek-chat"
        ):
            chunk_count += 1
            print(f"Chunk {chunk_count}: {chunk}", end="", flush=True)
            
            # 限制输出数量
            if chunk_count > 50:
                break
        
        print(f"\n✅ 流式测试完成，共 {chunk_count} 个chunk")
        return True
        
    except Exception as e:
        print(f"❌ 测试失败: {e}")
        import traceback
        traceback.print_exc()
        return False

if __name__ == "__main__":
    asyncio.run(test_simple_stream()) 